package com.wtgroup.demo.mianshi.jvm.GC;

import org.openjdk.jmh.annotations.*;

/**
 * @author dafei
 * @version 0.1
 * @date 2021/3/17 18:23
 */
public class D3_Stack {
    static int NUM = 10000;

    /**
     * m1 写法更优.
     * m2 栈中很多新对象, 循环没有结束, 可能得不到回收.
     * */


    public void m1() {
        Object o = null;
        for (int i = 0; i < NUM; i++) {
            o = new Object();
        }
    }

    public void m2() {
        for (int i = 0; i < NUM; i++) {
            Object o = new Object();
        }
    }

}
